package model;

import java.util.ArrayList;
import java.util.List;

import employee.Employee;
import lecture.Lecture;
import view.View;

public class Course extends Entity{
	protected String code = null;
	protected List<Lecture> lectures = null;
	protected List<Employee> employees = null;
	protected List<View> views = null;

	public Course(){
		this.code = "Default";
		this.lectures = new ArrayList<Lecture>();
		this.employees = new ArrayList<Employee>();
		this.views = new ArrayList<View>();
	}
	
	public Course(String name, String code)
	{
		super(name);
		this.code = code;
		this.lectures = new ArrayList<Lecture>();
		this.employees = new ArrayList<Employee>();
		this.views = new ArrayList<View>();
	}

	public void addLecture(Lecture l)
	{
		this.lectures.add(l);
	}
	
	public boolean removeLecture(Lecture l)
	{
		return this.lectures.remove(l) ;
	}
	
	public void addEmployee(Employee e)
	{
		this.employees.add(e);
	}
	
	public boolean removeEmployee(Employee e)
	{
		return this.employees.remove(e) ;
	}
	
	public void addView(View v)
	{
		this.views.add(v);
	}
	
	public boolean removeView(View v)
	{
		return this.views.remove(v);
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public List<Lecture> getLectures() {
		return lectures;
	}

	public void setLectures(List<Lecture> lectures) {
		this.lectures = lectures;
	}

	public List<Employee> getEmployees() {
		return employees;
	}

	public void setEmployees(List<Employee> employees) {
		this.employees = employees;
	}

	public List<View> getViews() {
		return views;
	}

	public void setViews(List<View> views) {
		this.views = views;
	}

	public String toString()
	{
		StringBuilder tmp = new StringBuilder("Course");
		tmp.append("\nname: "); tmp.append(this.getName()); 
		tmp.append("\ncode: "); tmp.append(this.code);
		tmp.append("\nlectures: "); for(Lecture l: this.lectures) {tmp.append(l.getName()); tmp.append(' ');};
		tmp.append("\nlemployees: "); for(Employee l: this.employees) {tmp.append(l.getFirstName()); tmp.append(' ');tmp.append(l.getName());};
		tmp.append("\npviews: "); for(View v:this.views) {tmp.append(v.getName()); tmp.append(' ');};
		return tmp.toString();
	}

}
